HAL NAND types migration

This section provides information about the HAL NAND types migration.

HAL NAND type definition

HAL NAND callback ID type definition

HAL1

HAL2

typedef enum
{
  HAL_NAND_MSP_INIT_CB_ID,
  HAL_NAND_MSP_DEINIT_CB_ID,
  HAL_NAND_IT_CB_ID
} HAL_NAND_CallbackIDTypeDef;
Removed.
Notes:

The callback registration in HAL2 is handled by specific functions for each NAND event. See Registers NAND user callback. and Unregisters NAND user callback. for more details.

Related concept: Individual callback registration APIs replace global register and unregister functions


HAL NAND state type definition

Note

  • HAL_NAND_STATE_READY is replaced with HAL_NAND_STATE_IDLE.

  • HAL_NAND_STATE_BUSY is replaced with HAL_NAND_STATE_ACTIVE.

  • HAL_NAND_STATE_ERROR is replaced with HAL_NAND_STATE_FAULT.

HAL1

HAL2

typedef enum
{
  HAL_NAND_STATE_RESET,
  /* ------------ */
  /* ------------ */
  /* ------------ */
  HAL_NAND_STATE_READY,
  HAL_NAND_STATE_BUSY,
  HAL_NAND_STATE_ERROR
} HAL_NAND_StateTypeDef;
typedef enum
{
  HAL_NAND_STATE_RESET,
  HAL_NAND_STATE_INIT,
  HAL_NAND_STATE_CONFIGURED,
  HAL_NAND_STATE_MEMORY_CONFIGURED,
  HAL_NAND_STATE_IDLE,
  HAL_NAND_STATE_ACTIVE,
  HAL_NAND_STATE_FAULT
} hal_nand_state_t;

Related concepts:


HAL NAND initialization and timing type definition

HAL1

HAL2

typedef struct
{
  uint32_t NandBank;
  uint32_t Waitfeature;
  /* ------------ */
  uint32_t EccComputation;
  uint32_t ECCPageSize;




  uint32_t MemoryDataWidth;
  /* ------------ */
  /* ------------ */
  /* ------------ */
  /* ------------ */
  uint32_t TCLRSetupTime;
  uint32_t TARSetupTime;
  /* ------------ */
} FMC_NAND_InitTypeDef;

 typedef struct
{
  uint32_t SetupTime;
  uint32_t WaitSetupTime;
  uint32_t HoldSetupTime;
  uint32_t HiZSetupTime;
} FMC_NAND_PCC_TimingTypeDef;
 typedef struct
{
  /* NAND bank selected during the initialization phase */
  hal_nand_wait_feature_status_t wait_feature_status;
  hal_nand_ecc_algorithm_t       ecc_algorithm;
  /* ECC computation is enabled or disabled after configuration phase using the dedicated enable and disable APIs. */
  hal_nand_chunk_size_t          chunk_size;
}hal_nand_config_t;

 typedef struct
{
 hal_nand_data_width_t           data_width;
 hal_nand_extra_command_status_t extra_command_status;
 uint32_t                        extra_command_timeout_us;
 uint32_t                        program_timeout_us;
 uint32_t                        erase_timeout_ms;
 uint32_t                        tclr_setup_time_nsec;
 uint32_t                        tar_setup_time_nsec;
 hal_nand_timings_t              timing;
} hal_nand_memory_config_t;

typedef struct
{
  uint32_t setup_time_ns;
  uint32_t wait_time_ns;
  uint32_t hold_time_ns;
  uint32_t hiz_time_ns;
} hal_nand_timings_t;

Related concepts:

Note

In HAL1, NAND structures are available in fmc core header file, whereas in HAL2, they’re moved to HAL_NAND header file. Refer to : HAL NAND initialization and configuration functions migration


HAL NAND address type definition

HAL1

HAL2

typedef struct
{
  uint16_t Page;
  uint16_t Plane;
  uint16_t Block;
} NAND_AddressTypeDef;
Removed.
In HAL1, the APIs operated on NAND memory using a structured NAND address provided through the NAND_AddressTypeDef structure.
In HAL2, this structure is removed, and the APIs now use directly the page or block index within the entire memory.

Related use case: Program and read one single page in polling mode


HAL NAND device configuration type definition

Note

  • In HAL1, the plane size and plane number are provided but, according to ONFI references, are not actually required for address handling. In HAL2 the plane related fields are removed and the LUN number is added, which is the parameter needed for address management.

  • In HAL2, the ExtraCommandEnable parameter is moved to the memory configuration structure hal_nand_memory_config_t.

HAL1

HAL2

typedef struct
{
  uint32_t        PageSize;
  uint32_t        SpareAreaSize;
  uint32_t        BlockSize;
  uint32_t        BlockNbr;
  uint32_t        PlaneNbr;
  uint32_t        PlaneSize;
  /* ------------ */
  FunctionalState ExtraCommandEnable;
} NAND_DeviceConfigTypeDef;
typedef struct
{
  uint32_t page_size_byte;
  uint32_t spare_area_size_byte;
  uint32_t page_nbr_per_block;
  uint32_t block_nbr;
  /* ------------ */
  /* ------------ */
  uint32_t lun_nbr;
  /* ------------ */
} hal_nand_partition_config_t;

Related concept: Replaced TypeDef suffix with _t in type names


HAL NAND handle type definition

HAL1

HAL2

typedef NAND_HandleTypeDef;
hal_nand_handle_t

Related concepts:


HAL NAND ID type definition

Note

The structure definition is unchanged, only field naming is slightly updated.

HAL1

HAL2

typedef struct
{
  uint8_t Maker_Id;
  uint8_t Device_Id;
  uint8_t Third_Id;
  uint8_t Fourth_Id;
} NAND_IDTypeDef;
typedef struct
{
  uint8_t manufacturer_code;
  uint8_t device_id;
  uint8_t third_id;
  uint8_t fourth_id;
} hal_nand_id_t;

Related concept: Replaced TypeDef suffix with _t in type names


HAL NAND callback type definition

Note

In HAL1, HAL_NAND_ITCallback() is used as status memory notifications (rising, falling, and high-level on the ready busy signal), with memory status reading handled in the user code. In HAL2, the HAL_NAND_ITCallback() status callback is removed, as the memory status is retrieved internally within the process APIs.

Related concept: Replaced TypeDef suffix with _t in type names


HAL NAND constant definition

FMC NAND wait feature

HAL1

HAL2



#define FMC_NAND_WAIT_FEATURE_DISABLE
#define FMC_NAND_WAIT_FEATURE_ENABLE
typedef enum
{
 HAL_NAND_WAIT_FEATURE_DISABLED
 HAL_NAND_WAIT_FEATURE_ENABLED
} hal_nand_wait_feature_status_t;

Related concepts:

Note

In HAL1, NAND defines are available in fmc core header file, whereas in HAL2, they’re converted into enumerated type in HAL_NAND header file. Refer to : HAL NAND initialization and configuration functions migration


FMC NAND data width

HAL1

HAL2



#define FMC_NAND_MEM_BUS_WIDTH_8
#define FMC_NAND_MEM_BUS_WIDTH_16
typedef enum
{
 HAL_NAND_DATA_BUS_WIDTH_8_BIT
 HAL_NAND_DATA_BUS_WIDTH_16_BIT
} hal_nand_wait_feature_status_t;

Related concepts:

Note

In HAL1, NAND defines are available in fmc core header file, whereas in HAL2, they’re converted into enumerated type in HAL_NAND header file. Refer to : HAL NAND initialization and configuration functions migration


FMC NAND ECC

HAL1

HAL2

#define FMC_NAND_ECC_DISABLE
#define FMC_NAND_ECC_ENABLE
Removed.
In HAL2, the ECC computation is enabled and disabled directly by calling the HAL_NAND_ECC_Enable() and HAL_NAND_ECC_Disable() APIs.

FMC NAND ECC page size

HAL1

HAL2



#define FMC_NAND_ECC_PAGE_SIZE_256BYTE
#define FMC_NAND_ECC_PAGE_SIZE_512BYTE
#define FMC_NAND_ECC_PAGE_SIZE_1024BYTE
#define FMC_NAND_ECC_PAGE_SIZE_2048BYTE
#define FMC_NAND_ECC_PAGE_SIZE_4096BYTE
#define FMC_NAND_ECC_PAGE_SIZE_8192BYTE
typedef enum
{
 HAL_NAND_CHUNK_SIZE_256_BYTE
 HAL_NAND_CHUNK_SIZE_512_BYTE
 HAL_NAND_CHUNK_SIZE_1024_BYTE
 HAL_NAND_CHUNK_SIZE_2048_BYTE
 HAL_NAND_CHUNK_SIZE_4096_BYTE
 HAL_NAND_CHUNK_SIZE_8192_BYTE
} hal_nand_wait_feature_status_t;

Note

In HAL1, NAND defines are available in fmc core header file, whereas in HAL2, they’re converted into enumerated type in HAL_NAND header file. Refer to : HAL NAND initialization and configuration functions migration